package model.bo;


import java.io.Serializable;

import model.bean.Curriculo;
import model.persistencia.dao.CurriculoDAO;
import model.persistencia.dao.HibernateUtil;

public class CurriculoBO implements Serializable {

	private static final long serialVersionUID = -1187968329483216255L;
	
	private CurriculoDAO curriculoDAO = new CurriculoDAO(Curriculo.class);

	public Curriculo incluir(Curriculo curriculo) throws Exception{ 
		HibernateUtil.getInstance().startTransaction();
		try {
			curriculo = curriculoDAO.save(curriculo);
			HibernateUtil.getInstance().commitTransaction();
		} catch (Exception e) {
			HibernateUtil.getInstance().rollbackTransaction();
		}
		return curriculo;
	}
	
	public void salvar(Curriculo curriculo) throws Exception{	 
		HibernateUtil.getInstance().startTransaction();
		try {
			curriculoDAO.merge(curriculo);
			HibernateUtil.getInstance().commitTransaction();
		} catch (Exception e) {
			HibernateUtil.getInstance().rollbackTransaction();
		}
	}
	
	public void excluir(Curriculo curriculo) throws Exception{
		HibernateUtil.getInstance().startTransaction();
		try {
			curriculoDAO.delete(curriculo);
			HibernateUtil.getInstance().commitTransaction();
		} catch (Exception e) {
			HibernateUtil.getInstance().rollbackTransaction();
		}
	}
	

	public Curriculo consultar(Curriculo curriculo) throws Exception{
		try {
			curriculo = curriculoDAO.load(curriculo.getId());
		} catch (Exception e) {
			HibernateUtil.getInstance().rollbackTransaction();
		}
		return curriculo;
	}

	
}
